package com.thomsonreuter.search.compare.config;

import com.thomsonreuter.search.compare.constants.CompareConstants;

import java.io.IOException;
import java.util.Properties;

public class PropertyConfig {
    private static PropertyConfig instance = null;
    Properties properties = new Properties();
    private PropertyConfig(){
    }

    public static PropertyConfig getInstance(){
        if(instance == null){
            instance = new PropertyConfig();
            instance.load();
        }

        return instance;
    }

    private PropertyConfig load(){
        try {
            properties.load(PropertyConfig.class.getClassLoader().getResourceAsStream("config.properties"));
        } catch (IOException e) {
            System.out.println("Load system config failed." + e.getMessage());
        }
        return instance;
    }

    public void setProperties(String key, String value){
        this.properties.setProperty(key,value);
    }

    public String getProperties(String name){
        return properties.getProperty(name);
    }

}
